
function throttle (fn, delay = 500) {
    let timer;
    return (...args) => {
        if (timer != undefined) return;
        timer = setTimeout(() => {
            fn.apply(this, args);
            timer = clearTimeout(timer)
        }, delay);
    }
}